<template>
  <div>
    <h1>管理员</h1>
    <button @click="sss">审核</button>
    <div v-show="iss">
      <ul>
        <li v-for="i in userlist" :key="i.id">{{i.content}} -- <span style="background-color: #07c160" @click="shenpi(i.id,i.user_id)">审核</span> </li>
      </ul>
      <button @click="clo">取消</button>
    </div>
    <br>
    <br>
    <button @click="sss1">添加礼物</button>
    <div v-show="iss1">
      礼物名: <van-field label="礼物名" v-model="name"/>
      积分: <van-field label="礼物名" v-model="integral"/>
      <button @click="addgify">添加</button>
      <button @click="clo1">取消</button>
    </div>


  </div>
</template>

<script>
import myaxios from "@/http/axios";

export default {
  name: "admin_caozuo",
  data() {
    return {
      data1: '',
      iss:false,
      iss1:false,
      uid:localStorage.getItem('userid'),
      userlist:[],
      name:'',
      integral:0
    }
  },
  methods: {
    sss(){
      this.iss = true
    },
    clo(){
      this.iss = false
    },
    sss1(){
      this.iss1 = true
    },
    clo1(){
      this.iss1 = false
    },
    showuser_list(){
      if (localStorage.getItem('is_admin')==2){
      myaxios('addnovel?uid='+this.uid,'get').then(res=>{
        this.userlist = res.list
      })
      }else {
        alert('无权限')
      }
    },
    addgify(){
      if (localStorage.getItem('is_admin')==2){
      myaxios('addgify','post',{'name':this.name,'integral':this.integral}).then(res=>{
        alert(res.msg)
      })
      }else {
        alert('无权限')
      }
    },
    shenpi(id,uid){
      myaxios('shenpi?uid='+uid+'&nid='+id,'get').then(res=>{
        alert(res.msg)
      })
    }
  },
  mounted() {
      this.showuser_list()
  }
}
</script>

<style scoped>

</style>